package jhta;

import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.SoftBevelBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import javax.swing.JPasswordField;
import javax.swing.ImageIcon;
import javax.swing.UIManager;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Image;
import java.io.File;

public class MemberUpdate extends JInternalFrame {

	MyTableRender render;
	TableRowSorter<TableModel> tSoter;
	ResultSet rs;
	ResultSetMetaData rsmd;
	PreparedStatement pst;
	Vector<String> v = new Vector<>();
	DefaultTableModel model;

	JavaDBConnection jdbc;
	Connection conn;
	
	String re; // 등록자 이름
	String code; // 관리자인지 기수인지
	Main mn;
	String find = "";
	String sql = "";
	int count = 0;

	String fileName = "noname"; // 사진 저장을 위한 경로를 만들어주기 위해서
	String folder = "img\\logo\\"; // 이미지를 저장할 경로 폴더 설정을 위해서
	
	private JComboBox cb_search;
	private JTextField findStr;
	private JButton button;
	private JScrollPane scrollPane;
	private JPanel panel;
	private JLabel lbx;
	private JLabel label_2;
	private JLabel label_3;
	private JLabel label_4;
	private JTextField inputClass;
	private JTextField inputCode;
	private JTextField inputName;
	private JTextField inputPhone;
	private JButton btn_modi;
	private JLabel label_5;
	private JButton btn_Dele;
	private JTable table;
	private JPanel panel_2;
	private JButton button_1;
	private JComboBox cb_rgname;
	private JLabel label;
	private JButton button_2;
	private JPasswordField inputPassword;
	private JPanel panel_1;
	private JPanel panel_3;
	private JLabel txtLogo;
	private JButton button_3;
	private JPanel panel_4;
	private JPanel panel_5;
	private JLabel lblX;
	private JButton btnNewButton;

	public MemberUpdate(Main m) {
		super("회원 조회 및 수정", false, true, true, true);
		getContentPane().setBackground(SystemColor.text);
		addInternalFrameListener(new InternalFrameAdapter() {
			@Override
			public void internalFrameActivated(InternalFrameEvent arg0) {
				cb_rgname();
			}

			@Override
			public void internalFrameClosing(InternalFrameEvent arg0) {
				mn.mUpdate = null;
			}
		});
		setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
		setBounds(100, 100, 540, 712);
		getContentPane().setLayout(null);
		getContentPane().add(getScrollPane());
		getContentPane().add(getPanel());
		getContentPane().add(getBtn_Dele());
		getContentPane().add(getBtn_modi());
		getContentPane().add(getButton_1_1());
		getContentPane().add(getButton_2());
		getContentPane().add(getPanel_4());
		getContentPane().add(getBtnNewButton());
		this.mn = m;
		jdbc = new JavaDBConnection();
		conn = jdbc.getConn();

	}

	public void Xreset() {
		if (findStr.getText().equals("")) {
			lblX.setVisible(false);
		} else {
			lblX.setVisible(true);
		}
	}

	public void sqlRun(String a) {
		try {
			PreparedStatement pst = conn.prepareStatement(a);
			ResultSet rs = pst.executeQuery();

			while (rs.next()) {
				v = new Vector<String>();
				v.add(rs.getString(1));
				v.add(rs.getString(2));
				v.add(rs.getString(3));
				v.add(rs.getString(4));
				v.add(rs.getString(5));
				model.addRow(v);
				count++;
			}

			rs.close();
			pst.close();

		} catch (Exception ex) {
			ex.getStackTrace();
		}
	}

	public void MemSearch() {
		count = 0;
		// 모델을 0번줄로 셋팅하므로써 테이블 초기화
		if (model.getRowCount() != 0)
			model.setNumRows(0);
		if (findStr.getText().equals("")) {
			if (cb_search.getSelectedItem().equals("전체")) {
				String totSql = "select m.no, c.code_Big, c.code_name, m.name, m.phone from bookmember m , code c where m.code_no=c.code_no order by m.no asc";
				sqlRun(totSql);

			} else if (cb_search.getSelectedItem().equals("수강생")) {
				String stuSql = "select m.no, c.code_Big, c.code_name, m.name, m.phone from bookmember m , code c where m.code_no=c.code_no and c.code_big='A3' order by m.no asc";
				sqlRun(stuSql);

			} else if (cb_search.getSelectedItem().equals("관리자")) {
				String manaSql = "select m.no, c.code_Big, c.code_name, m.name, m.phone from bookmember m, code c where m.code_no=c.code_no and c.code_big='A2' order by m.no asc";
				sqlRun(manaSql);
			}

		} else if (!findStr.getText().equals("")) {
			find = findStr.getText();
			if (cb_search.getSelectedItem().equals("전체")) {
				String totSql = "select m.no, c.code_Big, c.code_name, m.name, m.phone from bookmember m inner join code c on m.code_no=c.code_no where m.name like ? or m.phone like ? or c.code_name like ? order by no asc";
				sqlRun2(totSql);

			} else if (cb_search.getSelectedItem().equals("수강생")) {
				String stuSql = "select m.no, c.code_Big, c.code_name, m.name, m.phone from bookmember m inner join code c on m.code_no=c.code_no and c.code_big='A3' where m.name like ? or m.phone like ? or c.code_name like ? order by no asc";
				sqlRun2(stuSql);

			} else if (cb_search.getSelectedItem().equals("관리자")) {
				String manaSql = "select m.no, c.code_Big, c.code_name, m.name, m.phone from bookmember m inner join code c on m.code_no=c.code_no and c.code_big='A2' where m.name like ? or m.phone like ? or c.code_name like ? order by no asc";
				sqlRun2(manaSql);
			}
		}
		System.out.println(count);

	}

	public void sqlRun2(String b) {// 텍스트상자의 내용으로 검색(번호,이름,전화번호,수강명)
		try {
			PreparedStatement pstmt = conn.prepareStatement(b);
			pstmt.setString(1, "%" + find + "%");
			pstmt.setString(2, "%" + find + "%");
			pstmt.setString(3, "%" + find + "%");

			ResultSet rs = pstmt.executeQuery();

			while (rs.next()) {

				v = new Vector<String>();
				v.add(rs.getString(1));
				v.add(rs.getString(2));
				v.add(rs.getString(3));
				v.add(rs.getString(4));
				v.add(rs.getString(5));
				model.addRow(v);
				count++;

			}

			rs.close();
			pstmt.close();

		} catch (Exception ex) {
			ex.getStackTrace();
		}

	}

	public void setData(int n) {// 테이블에서 데이터를 더블 클릭시 수정할 데이터 세팅
		String sql = "select * from bookmember where no = ?";
		try {
			PreparedStatement pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, n);
			ResultSet rs = pstmt.executeQuery();

			if (rs.next()) {
				inputCode.setText(rs.getString(1));
				inputName.setText(rs.getString(2));
				inputPhone.setText(rs.getString(3));
				inputPassword.setText(rs.getString(4));

				cb_rgname();
				cb_rgname.setSelectedItem(re);
				inputClass.setText(code);
			}

			rs.close();
			pstmt.close();

			if (!inputClass.getText().equals("관리자")) {
				inputPassword.setEditable(false);
				inputPassword.setEnabled(false);
			} else if (inputClass.getText().equals("관리자")) {
				inputPassword.setEditable(true);
				inputPassword.setEnabled(true);
			}

		} catch (Exception ex) {
			ex.getStackTrace();
		}
	}

	public void setRe(int n) {
		String setResql = "select m2.name from bookmember m inner join bookmember m2 on m.rno = m2.no where m.no = ?";
		try {
			PreparedStatement pst = conn.prepareStatement(setResql);
			pst.setInt(1, n);
			ResultSet rs = pst.executeQuery();
			if (rs.next()) {
				re = rs.getString(1);
			}

			rs.close();
			pst.close();
		} catch (Exception ex) {
			ex.getStackTrace();
		}
	}

	public void setCode(int n) {
		String setResql = "select c.code_name from bookmember m inner join code c on m.code_no = c.code_no where m.no = ?";
		try {
			PreparedStatement pst = conn.prepareStatement(setResql);
			pst.setInt(1, n);

			ResultSet rs = pst.executeQuery();

			if (rs.next()) {
				code = rs.getString(1);
			}

			rs.close();
			pst.close();
		} catch (Exception ex) {
			ex.getStackTrace();
		}
	}

	public void cb_rgname() {// 수강생>>등록자 콤보박스
		try {
			cb_rgname.removeAllItems();
			String rgname = "select distinct m.name from bookmember m left outer join code c on m.code_no= c.code_no where c.code_name='관리자' order by m.name asc";

			PreparedStatement pst3 = conn.prepareStatement(rgname);
			ResultSet rs = pst3.executeQuery();
			cb_rgname.addItem(Main.USER_NAME);
			while (rs.next()) {
				cb_rgname.addItem(rs.getString(1));
			}

			rs.close();
			pst3.close();
		} catch (Exception rg) {
			rg.getStackTrace();
		}
	}

	public String pw() {// 패스워드
		String k = "";
		char[] pw = inputPassword.getPassword();
		for (int i = 0; i < pw.length; i++) {
			k += pw[i];

		}
		return k;
	}

	public void dataUpS() {// 학생일때 수정

		String i = inputName.getText();
		String p = inputPhone.getText();
		String mi = (String) cb_rgname.getSelectedItem();
		int n = Integer.parseInt(inputCode.getText());
		String sql = "update bookmember set name=?,phone=?,rdate=sysdate,rno=(select no from bookMember where name=? and rno is null) where no=?";

		try {
			PreparedStatement pstmt = conn.prepareStatement(sql);

			pstmt.setString(1, i);
			pstmt.setString(2, p);
			pstmt.setString(3, mi);
			pstmt.setInt(4, n);

			pstmt.executeUpdate();
			pstmt.close();
		} catch (Exception ex) {
			ex.getStackTrace();
		}
	}

	public void dataUpM() {// 관리자일때 수정

		String i = inputName.getText();
		String p = inputPhone.getText();
		char[] pw = inputPassword.getPassword();
		int n = Integer.parseInt(inputCode.getText());

		String sql = "update bookmember set name=?,phone=?, password=?, rdate=sysdate where no=?";
		try {
			PreparedStatement pstmt = conn.prepareStatement(sql);
			pstmt.setString(1, i);
			pstmt.setString(2, p);
			pstmt.setString(3, pw());
			pstmt.setInt(4, n);

			pstmt.executeUpdate();
			pstmt.close();
		} catch (Exception ex) {
			ex.getStackTrace();
		}
	}

	public void dataUp() {
		if (inputClass.getText().equals("관리자")) {// 관리자일때
			dataUpM();

		} else if (!inputClass.getText().equals("관리자")) {// 기수일때
			dataUpS();
		}
	}

	public void dataDele() {
		try {
			int n = Integer.parseInt(inputCode.getText());
			String sql = "delete from bookmember where no=?";
			PreparedStatement pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, n);
			pstmt.executeUpdate();
			pstmt.close();
			reSet();

		} catch (Exception ex) {
			ex.getMessage();
		}
	}

	public void ListDele() {

		for (int i = 0; i < count; i++) {
			int temp = Integer.parseInt(table.getValueAt(i, 0).toString());
			String sql = "delete from bookmember where no=?";

			try {
				PreparedStatement pst = conn.prepareStatement(sql);
				pst.setInt(1, temp);

				pst.executeUpdate();
				pst.close();

			} catch (SQLException e) {
				e.printStackTrace();
			}

		}
		
		
		int a = JOptionPane.showConfirmDialog(null, "선택된 목록의 데이터가 삭제하시겠습니까?");
		if(a==JOptionPane.OK_OPTION){
			JOptionPane.showMessageDialog(null, "삭제되었습니다.");
				if (model.getRowCount() > 0) { // 행의 수
					for (int i = model.getRowCount() - 1; i > -1; i--) {
					model.removeRow(i);//테이블을 초기화
					
				}			
		}else{
			return;
		}
		}
	}

	public void reSet() {// 초기화

		inputClass.setText("");
		inputCode.setText("");
		inputName.setText("");
		inputPhone.setText("");
		inputPassword.setText("");
		cb_rgname.setSelectedIndex(0);

	}

	private JComboBox getCb_search() {
		if (cb_search == null) {
			String[] t = { "전체", "관리자", "수강생" };

			cb_search = new JComboBox(t);
			cb_search.setBounds(12, 6, 111, 25);
		}
		return cb_search;
	}

	// enter치면 검색
	private JTextField getFindStr() {
		if (findStr == null) {
			findStr = new JTextField();
			findStr.setMinimumSize(new Dimension(200, 25));
			findStr.setPreferredSize(new Dimension(200, 25));
			findStr.setBorder(null);
			findStr.addKeyListener(new KeyAdapter() {
				@Override
				public void keyPressed(KeyEvent e) {
					if (e.getKeyCode() == KeyEvent.VK_ENTER) {

						MemSearch();
					}
				}

				@Override
				public void keyReleased(KeyEvent arg0) {
					Xreset();
					// lblX.setVisible(true);
				}
			});
			findStr.setColumns(10);
		}
		return findStr;
	}

	private JButton getButton() {
		if (button == null) {
			button = new JButton("검색");
			button.setOpaque(false);
			button.setBorder(null);
/*			button.setIcon(new ImageIcon(MemberUpdate.class
					.getResource("/jhta/ImageFolder/y.png")));*/
			button.setBounds(422, 5, 66, 27);
			button.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					MemSearch();

					// reSet();
				}
			});
		}
		return button;
	}

	private JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setBounds(12, 57, 500, 262);
			scrollPane.setViewportView(getTable());
		}
		return scrollPane;
	}

	private JPanel getPanel() {
		if (panel == null) {
			panel = new JPanel();
			panel.setBorder(UIManager.getBorder("TextField.border"));
			panel.setLayout(null);
			panel.setBounds(12, 359, 500, 254);
			panel.add(getPanel_2());
			panel.add(getPanel_1_1());
			panel.add(getPanel_3());
		}
		return panel;
	}

	private JLabel getLbx() {
		if (lbx == null) {
			lbx = new JLabel("관리자/기수");
			lbx.setBounds(-3, 16, 87, 15);
			lbx.setHorizontalAlignment(SwingConstants.RIGHT);
		}
		return lbx;
	}

	private JLabel getLabel_2() {
		if (label_2 == null) {
			label_2 = new JLabel("회원번호");
			label_2.setBounds(-3, 51, 87, 15);
			label_2.setHorizontalAlignment(SwingConstants.RIGHT);
		}
		return label_2;
	}

	private JLabel getLabel_3() {
		if (label_3 == null) {
			label_3 = new JLabel("성명");
			label_3.setBounds(-3, 86, 87, 15);
			label_3.setHorizontalAlignment(SwingConstants.RIGHT);
		}
		return label_3;
	}

	private JLabel getLabel_4() {
		if (label_4 == null) {
			label_4 = new JLabel("연락처");
			label_4.setBounds(-3, 121, 87, 15);
			label_4.setHorizontalAlignment(SwingConstants.RIGHT);
		}
		return label_4;
	}

	private JTextField getInputClass() {
		if (inputClass == null) {
			inputClass = new JTextField();
			inputClass.setEnabled(false);
			inputClass.setBounds(96, 10, 197, 25);
			inputClass.setColumns(10);
		}
		return inputClass;
	}

	private JTextField getInputCode() {
		if (inputCode == null) {
			inputCode = new JTextField();
			inputCode.setEnabled(false);
			inputCode.setBounds(96, 46, 197, 25);
			inputCode.setColumns(10);
		}
		return inputCode;
	}

	private JTextField getInputName() {
		if (inputName == null) {
			inputName = new JTextField();
			inputName.setBounds(96, 82, 197, 25);
			inputName.setColumns(10);
		}
		return inputName;
	}

	private JTextField getInputPhone() {
		if (inputPhone == null) {
			inputPhone = new JTextField();
			inputPhone.setBounds(96, 118, 197, 25);
			inputPhone.setColumns(10);
		}
		return inputPhone;
	}

	private JButton getBtn_modi() {
		if (btn_modi == null) {
			btn_modi = new JButton("수정");
			btn_modi.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					if (cb_rgname.getSelectedIndex() < 0) {
						JOptionPane.showMessageDialog(null, "등록자를 선택해주세요!");
						return;
					}

					if (!inputClass.getText().equals("")) {
						int a = JOptionPane.showConfirmDialog(null,
								"정말 수정하시겠습니까?");
						if (a == JOptionPane.OK_OPTION) {
							dataUp();
							MemSearch();
							reSet();

						}
					}
				}
			});
			btn_modi.setBounds(77, 623, 100, 50);
		}
		return btn_modi;
	}

	private JLabel getLabel_5() {
		if (label_5 == null) {
			label_5 = new JLabel("암호");
			label_5.setBounds(27, 156, 57, 15);
			label_5.setHorizontalAlignment(SwingConstants.RIGHT);
		}
		return label_5;
	}

	private JButton getBtn_Dele() {
		if (btn_Dele == null) {
			btn_Dele = new JButton("삭제");
			btn_Dele.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {

					if (!inputClass.getText().equals("")) {
						int a = JOptionPane.showConfirmDialog(null,
								"정말 삭제하시겠습니까?");
						if (a == JOptionPane.OK_OPTION) {
							dataDele();
							MemSearch();
						}
					}
				}
			});
			btn_Dele.setBounds(189, 623, 100, 50);
		}
		return btn_Dele;
	}

	private JTable getTable() {
		if (table == null) {
			String[] t = { "번호", "분류", "과정명", "성명", "연락처" };
			model = new DefaultTableModel(t, 0) {
				public boolean isCellEditable(int rowIndex, int mColIndex) {
					return false;
				}
			};
			table = new JTable(model);
			table.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseClicked(MouseEvent e) {
					int row = table.getSelectedRow();
					setRe(Integer.parseInt(table.getValueAt(row, 0).toString()));
					setCode(Integer.parseInt(table.getValueAt(row, 0)
							.toString()));
					setData(Integer.parseInt(table.getValueAt(row, 0)
							.toString()));
				}
			});
			tSoter = new TableRowSorter(model);
			table.setRowSorter(tSoter);

			char[] c = { 'c', 'c', 'l', 'l', 'l' };
			int[] w = { 40, 70, 140, 140, 120 };
			render = new MyTableRender(table, c, w);// 넓이정하기

		}
		return table;
	}

	private JPanel getPanel_2() {
		if (panel_2 == null) {
			panel_2 = new JPanel();
			panel_2.setBounds(183, 10, 305, 232);
			panel_2.setLayout(null);
			panel_2.add(getLbx());
			panel_2.add(getLabel_2());
			panel_2.add(getLabel_3());
			panel_2.add(getLabel_4());
			panel_2.add(getInputClass());
			panel_2.add(getInputCode());
			panel_2.add(getInputName());
			panel_2.add(getInputPhone());
			panel_2.add(getLabel_5());
			panel_2.add(getCb_rgname());
			panel_2.add(getLabel());
			panel_2.add(getInputPassword());
		}
		return panel_2;
	}

	private JButton getButton_1_1() {
		if (button_1 == null) {
			button_1 = new JButton("취소");
			button_1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					reSet();
				}
			});
			button_1.setBounds(301, 623, 100, 50);
		}
		return button_1;
	}

	private JComboBox getCb_rgname() {
		if (cb_rgname == null) {
			cb_rgname = new JComboBox();
			cb_rgname.setBounds(96, 191, 197, 27);
		}
		return cb_rgname;
	}

	private JLabel getLabel() {
		if (label == null) {
			label = new JLabel("등록자");
			label.setHorizontalAlignment(SwingConstants.RIGHT);
			label.setBounds(-3, 200, 87, 15);
		}
		return label;
	}

	private JButton getButton_2() {
		if (button_2 == null) {
			button_2 = new JButton("닫기");
			button_2.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					reSet();
					setVisible(false);

				}
			});
			button_2.setBounds(413, 623, 100, 50);
		}
		return button_2;
	}

	private JPasswordField getInputPassword() {
		if (inputPassword == null) {
			inputPassword = new JPasswordField();
			inputPassword.setBounds(96, 154, 197, 25);
		}
		return inputPassword;
	}

	private JPanel getPanel_1_1() {
		if (panel_1 == null) {
			panel_1 = new JPanel();
			panel_1.setBorder(UIManager.getBorder("TextField.border"));
			panel_1.setBounds(160, 27, 2, 165);
		}
		return panel_1;
	}

	private JPanel getPanel_3() {
		if (panel_3 == null) {
			panel_3 = new JPanel();
			panel_3.setLayout(null);
			panel_3.setBorder(new LineBorder(SystemColor.inactiveCaption));
			panel_3.setBackground(SystemColor.inactiveCaptionBorder);
			panel_3.setBounds(12, 36, 140, 156);
			panel_3.add(getTxtLogo());
			panel_3.add(getButton_3());
		}
		return panel_3;
	}

	private JLabel getTxtLogo() {
		if (txtLogo == null) {
			txtLogo = new JLabel("");
			
			txtLogo.setIcon(new ImageIcon("C:\\workspace\\svn_bookrent1\\ImageFolder\\img.jpg"));
			txtLogo.setHorizontalAlignment(SwingConstants.CENTER);
			txtLogo.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null,
					null, null));
			txtLogo.setBounds(20, 10, 100, 100);
		}
		return txtLogo;
	}

	public void logo() {// 로고 이미지 수정
		try {
			JFileChooser fc = new JFileChooser();
			int yn = fc.showOpenDialog(this);
			if (yn == JFileChooser.APPROVE_OPTION) {
				File f = fc.getSelectedFile();
				fileName = f.getPath();

				// 이미지를 가져온 후 그 이미지의 사이즈를 조정해서 셋팅
				Image imagetemp = new ImageIcon(fileName).getImage(); // 이미지생성
				Image image = imagetemp.getScaledInstance(100, 100,
						Image.SCALE_SMOOTH); // 이미지리사이즈
				ImageIcon icontemp = new ImageIcon(image); // 리사이즈된 이미지아이콘생성
				txtLogo.setText("");
				txtLogo.setIcon(icontemp);
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	
	private JButton getButton_3() {
		if (button_3 == null) {
			button_3 = new JButton("사진추가");
			button_3.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {

					logo();
		
					
				}
			});
			button_3.setBounds(20, 116, 100, 30);
		}
		return button_3;
	}

	private JPanel getPanel_4() {
		if (panel_4 == null) {
			panel_4 = new JPanel();
			panel_4.setBackground(SystemColor.inactiveCaption);
			panel_4.setBounds(12, 11, 497, 40);
			panel_4.setLayout(null);
			panel_4.add(getCb_search());
			panel_4.add(getButton());
			panel_4.add(getPanel_5());
		}
		return panel_4;
	}

	private JPanel getPanel_5() {
		if (panel_5 == null) {
			panel_5 = new JPanel();
			panel_5.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
			panel_5.setBackground(Color.WHITE);
			panel_5.setBorder(UIManager.getBorder("TextField.border"));
			panel_5.setBounds(135, 6, 281, 25);
			panel_5.setLayout(new BorderLayout(0, 0));
			panel_5.add(getFindStr(), BorderLayout.CENTER);
			panel_5.add(getLblX(), BorderLayout.EAST);
		}
		return panel_5;
	}

	private JLabel getLblX() {
		if (lblX == null) {
			lblX = new JLabel("");
			lblX.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseClicked(MouseEvent e) {
					findStr.setText("");
					lblX.setVisible(false);
				}
			});
			lblX.setVisible(false);
			lblX.setIcon(new ImageIcon("C:\\workspace\\svn_bookrent1\\ImageFolder\\x.png"));
		
		}
		return lblX;
	}

	private JButton getBtnNewButton() {
		if (btnNewButton == null) {
			btnNewButton = new JButton("선택목록 삭제");
			btnNewButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					ListDele();

				}
			});
			btnNewButton.setBounds(332, 320, 182, 30);
		}
		return btnNewButton;
	}
}
